var baseUrl = "https://www.xaqtj.com/api/v1/";
var vm = new Vue({
    el: "#address",
    data: {
        addressList:[],
        limitNum:3,
        currentIndex:0,
        shippingMethod:1
    },
    filters: {

    },
    //初始化方法
    mounted:function(){
        this.$nextTick(function(){
            this.getAddressList();
        });
    },
    computed: {
        filterAddress : function(){
            return this.addressList.slice(0,this.limitNum);
        }
    },
    methods: {
        getAddressList:function(){
            var _this = this;
            axios.get(baseUrl + "json/place")
            .then(function (response) {
                console.log(response.data);
                if(response.data.status == 1) {
                    _this.addressList = response.data.result; 
                }
            })
            .catch(function (error) {
              console.log(error);
            });
        },
        loadMore:function(){
            if(this.limitNum == 3){
                this.limitNum = this.addressList.length;
            }else{
                this.limitNum = 3;
            }
            
        },
        //地址卡片设为默认
        setDefault:function(addressId){
            this.addressList.forEach(function(address) {
                if(address.addressId == addressId){
                    address.isDefault = true;
                }else{
                    address.isDefault = false;
                }
            });
        }
    }
});